package com.fau.wmbj.server.utils;

import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author jiawei
 * @version 1.0
 * @datetime 2024/7/3 下午5:53
 */

@Component
public class IPhysicalNamingStrategyStandardImpl extends PhysicalNamingStrategyStandardImpl {

    @Override
    public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
        String text = name.getText();
        if (StringUtils.contains(text, "act_")) {
            // 将表名全部转换成大写
            String tableName = name.getText().toUpperCase();
            return Identifier.toIdentifier(tableName);
        } else {
            return name;
        }
    }
}
